<template>
  <div class="search">
    <Desktop v-if="isDesktop"></Desktop>
    <Mobile v-else></Mobile>
  </div>
</template>

<script setup>
import { onActivated } from 'vue'
import { useRoute } from 'vue-router'
import { storeToRefs } from 'pinia'
import { useAppStore } from '@/store/app'
import { useHeadStore } from '@/store/head'
import asyncCompWithLoading from '@/utils/async-comp-with-loading'

const Desktop = asyncCompWithLoading(() => import('./Desktop.vue'))
const Mobile = asyncCompWithLoading(() => import('./Mobile.vue'))

const appStore = useAppStore()
const { isDesktop } = storeToRefs(appStore)

const { path, query } = useRoute()
const { keyword } = query

const { toSearchHead } = useHeadStore()

onActivated(() => toSearchHead({ path, keyword }))
</script>

<style lang="scss" scoped>
.search {
  width: 100%;
  height: 100%;
}
</style>
